import { useSelector, useDispatch } from "react-redux"
import numStatus from "@/store/NumStaets"
const View = () => {
    const dispatch = useDispatch()
    // 获取仓库数据
    const { num, sarr } = useSelector((state: RootState) => ({
        num: state.numStaets.num,
        sarr: state.arrStatus.sarr

    }))
    // 修改仓库数据6
    const changeNum = () => {
        // dispatch({ type: "字符串(认为是一个记号)", val: 3 })
        // dispatch({ type: 'add1' })
        dispatch({ type: 'add3', val: 200 })    
    }
    const changeNum2 = () => {
        dispatch(numStatus.asyncActions.asyncAdd1)
    }
    
    const changeArr = () => {
        dispatch({ type: 'sarrpush', val: 100 })
    }

    return (
        <div className="home">
            <p>这是Page1组件</p>
            <p>{num}</p>
            <button onClick={changeNum}> 同步</button>
            <button onClick={changeNum2}> 异步</button>
            <p>{sarr}</p>
            <button onClick={changeArr}> 按钮</button>
        </div>
    )
}

export default View 